<?php
/**
* エラーチェッククラス
**/
require_once( '../system/Class_M_DAO.php' );
class Class_M_NEWYEAR extends Class_M_DAO {
	//protected properties begin
	/**
	 *
	 * テーブル名
	 *
	 * @access    protected
	 * @var       string
	 *
	 */
	protected $_table = "M_NEWYEAR";
	
	/**
	 *
	 * 主キー名
	 *
	 * @access    protected
	 * @var       string
	 *
	 */
	protected $_pkey = "year_mark";
	
	/**
	 *
	 * ソート順
	 *
	 * @access    protected
	 * @var       string
	 *
	 */
	 protected $_order = "year_mark";
	 
	 protected $_cols     = array(
	 	"year_mark"  => array(AOKI_VARTYPE_STR),
		"d1229"      => array(AOKI_VARTYPE_STR),
		"d1230"      => array(AOKI_VARTYPE_STR),
		"d1231"      => array(AOKI_VARTYPE_STR),
		"d0101"      => array(AOKI_VARTYPE_STR),
	    "d0102"      => array(AOKI_VARTYPE_STR),
	    "d0103"      => array(AOKI_VARTYPE_STR),
		"d0104"      => array(AOKI_VARTYPE_STR),
		"memo_day1"  => array(AOKI_VARTYPE_STR),
		"memo_text1" => array(AOKI_VARTYPE_STR),
		"memo_day2"  => array(AOKI_VARTYPE_STR),
		"memo_text2" => array(AOKI_VARTYPE_STR),
		"memo_day3"  => array(AOKI_VARTYPE_STR),
		"memo_text3" => array(AOKI_VARTYPE_STR),
		"memo_day4"  => array(AOKI_VARTYPE_STR),
		"memo_text4" => array(AOKI_VARTYPE_STR),
	 );
	
	 protected $_checks  = array(
		"year_mark"      => array( "EXIST" ),
	 );
	 
	 //maxlength 
	 protected $_maxlens  = array(
		"year_mark"      =>  3 ,
	 );
	 public function search($where ,&$page = NULL ){	
		$sql = "SELECT a.*,b.shop_nums,(select  user_name FROM M_LOGIN where id  = a.u_user) as m_user_name from {$this->_table} a " .
				" left join (select year_mark,count(*) as shop_nums from M_NEWYEAR_SHOP group by year_mark )  b on  a.year_mark = b.year_mark  ";
		$sql = $sql."";
		$sqlCnt = "select count(*) as cnt  from  {$this->_table}  a  ";
		return  parent::search($where, $page, $sql, $sqlCnt) ;
	}
	 public function searchcsv($where  ){	
		$sql = "SELECT a.*,c.shop_cd,c.shop_name,(select  user_name FROM M_LOGIN where id  = a.u_user) as m_user_name from {$this->_table}  a ";
		$sql = $sql." left  join M_NEWYEAR_SHOP b on b.year_mark = a.year_mark " ;
		$sql = $sql." left  join M_SHOP c on b.shop_cd = c.shop_cd ";
		$page = NULL;
		return  parent::search($where ,$page ,$sql);
	}

	
}

?>